(*****************************************************************************
 * Delphi Plug-in Framework (DPF)
 * Copyright (C) 2006-2007 Tao Yuan
 *
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the
 * License at http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
 * the specific language governing rights and limitations under the License.                                                               }
 *
 * The Initial Developer of the Original Code is Tao Yuan. Portions created by
 * Tao Yuan are Copyright (C) Tao Yuan (taoy.cn att gmail dott com)
 * All rights reserved.
 *****************************************************************************)
unit RdPathResolver;

interface

uses
  Rcl,
  RdIntfs, RdClasses, RdIdentity;

type
  (**
  * This class is intended to establish correspondence between relative path
  * and absolute URL in context of plug-in or plug-in fragment.
  *
  * @see org.java.plugin.ObjectFactory#createPathResolver()
  *
  * @version $Id: PathResolver.java,v 1.7 2005/12/05 19:06:21 ddimon Exp $
  *)
  IPathResolver = interface(IRdInterface)
  ['{F280F06B-A432-48E9-ADE7-B923053E9269}']
    (**
    * Configures this resolver instance. Usually this method is called from
    * {@link ObjectFactory object factory} implementation.
    * @param config path resolver configuration data
    *)
    procedure configure(config: TExtendedProperties); stdcall;

    (**
    * Registers "home" URL for given plug-in element.
    * @param idt plug-in element
    * @param url "home" URL for a given plug-in element
    *)
    procedure registerContext(idt: IIdentity; url: string); stdcall;

    (**
    * Unregisters plug-in element from this path resolver.
    * @param id plug-in element identifier
    *)
    procedure unregisterContext(id: string); stdcall;
    
    (**
    * Returns URL of {@link #registerContext(Identity, URL) registered} plug-in
    * element context. If context for plug-in element with given ID not
    * registered, this method should throw an {@link IllegalArgumentException}.
    * In other words, this method shouldn't return <code>null</code>.
    * @param id plug-in element identifier
    * @return registered context "home" location
    *)
    function getRegisteredConext(id: string): string; stdcall;

    (**
    * @param id plug-in element identifier
    * @return <code>true</code> if context for plug-in element with given ID
    *         registered
    *)
    function isContextRegistered(id: string): Boolean; stdcall;
    function isResourceExists(url: string): Boolean; stdcall;

    (**
    * Should resolve given path to URL for a given identity.
    * @param identity plug-in element for which to resolve path
    * @param path path to be resolved
    * @return resolved absolute URL
    *)
    function resolvePath(identity: IIdentity; path: string): string; stdcall;
 end;


implementation

end.
